/*
 * Point.h
 *
 *  Created on: 25/01/2012
 *      Author: paula
 */

#ifndef POINT_H_
#define POINT_H_

#include <iostream>
using namespace std;

//
// Represents a point in 2D
//
struct Point {
	double coord [2]; // point coordinates

	// null constructor
	Point () { coord[0] = 0; coord[1] = 0; }

	// Constructor from coordinates x,y
	Point (double x, double y)  { coord[0] = x; coord[1] = y; }

	inline double& operator [] (int i)  { return coord[i]; }

	/* Comparison operator (less than)
	 *  -first y coordinate and after x coordinate
	 *  -used automatically in sort
	 */
	inline bool operator< (const Point& other) const {
		return ((coord[1]<other.coord[1])||((coord[1]==other.coord[1])&&(coord[0]<other.coord[0])));
	}

	inline bool operator<= (const Point& other) const {
			return ((coord[1]<other.coord[1])||((coord[1]==other.coord[1])&&(coord[0]<=other.coord[0])));
	}

    inline bool operator== (const Point& other) const {
                    return ((coord[1]==other.coord[1])&&(coord[0]==other.coord[0]));
    }



};



#endif /* POINT_H_ */
